package com.tiancheng.trade.payment.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tiancheng.trade.payment.bo.SettleFlowDetailMerchantBO;
import com.tiancheng.trade.payment.model.OrgPaymentChannel;
import com.tiancheng.trade.payment.model.PaymentFlowDetailSettle;
import com.tiancheng.trade.payment.vo.api.QueryFlowDetailVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @ClassName PaymentFlowDetailSettleMapper
 * @Description 支付明细结算信息 mapper
 * @Author kellen
 * @Date 2024/11/28 21:50
 */
@Mapper
public interface PaymentFlowDetailSettleMapper extends TYBaseMapper<PaymentFlowDetailSettle> {
    /**
     * 聚合应清分商户、商品编码
     *
     * @param expectSettleDate 结算日期
     * @param payChannel       支付渠道编码
     * @return
     */
    List<SettleFlowDetailMerchantBO> distinctSettleMerchant(LocalDate expectSettleDate, String payChannel);

    /**
     * 聚合等待清分的结算单
     *
     * @param expectSettleDate 结算日期
     * @param payChannel       支付渠道编码
     * @return
     */
    IPage<PaymentFlowDetailSettle> pageWaitSettles(@Param("expectSettleDate") LocalDate expectSettleDate,
                                                   @Param("payChannel") String payChannel,
                                                   Page<PaymentFlowDetailSettle> page);

    /**
     * 查询已经完成的结算单
     * @param settleIds
     * @return
     */
    List<PaymentFlowDetailSettle> completedSettles(@Param("settleIds") Set<Long> settleIds);

    /**
     * 等待结算的交易流水
     * 所有子订单流水都已经核销
     * @param payChannel 支付通道
     * @return
     */
    List<PaymentFlowDetailSettle> waitSettleAccountsFlows(@Param("payChannel") String payChannel);
}
